<?php
error_reporting("E_ALL");ini_set("display_errors", 1);
$getdata=$_REQUEST;
if(empty($getdata))$getdata=$_POST?$_POST:$_GET;
$type=empty($getdata['type'])?'':$getdata['type'];
include("include/function.php");
//header("content-Type: application/json; charset=utf-8");
$config = include("config.php");
include("include/".$config['DB_TYPE'].".class.php");
$db = new db;
$db->connect($config['DB_HOST'],$config['DB_USER'],$config['DB_PWD'],$config['DB_NAME'], $config['DB_PCONNECT']);
  
$sql = "select class_id,school_uuid,name,uuid from hema_school_class where status=1 and uuid='' and school_uuid<>''";
$list = $db->get_all($sql);
$class=[];
foreach($list as $v){
    $sql = "select classId from order_info where className='".$v['name']."' and classId<>'' and unitid='".$v['school_uuid']."'";
    $info = $db->get_one($sql);

    if(!empty($info['classId'])){
        $db->query("update hema_school_class set uuid='".$info['classId']."' where class_id=".$v['class_id']);
    }else{
        $sql = "select classId from order_info_hs where className='".$v['name']."' and classId<>'' and unitid='".$v['school_uuid']."'";
        $info = $db->get_one($sql);
    
        if(!empty($info['classId'])){
            $db->query("update hema_school_class set uuid='".$info['classId']."' where class_id=".$v['class_id']);
        }
    }
}

//echo count($sqlarr)."\n";
//echo implode(";\n",$sqlarr);
?>